<?php


namespace app\api\library\user\updateUserName;


use app\api\model\MallUser;

class V
{
    public static function run($param)
    {
        //查询有无openid
        _checkEmptyParam($param[ 'userId' ], '用户不能为空');
        _checkEmptyParam($param[ 'name' ], '昵称不能为空');
        if (false === MallUser::update(['name' => $param[ 'name' ]], ['id' => $param[ 'userId' ]])) {
            _outPut(204, '', '修改失败');
        }
        $userInfo = MallUser::where(['id' => $param[ 'userId' ]])->find();
        $res      = [
            'id'         => $userInfo[ 'id' ],
            'avatar_url' => $userInfo[ 'avatar_url' ],
            'name'       => $userInfo[ 'name' ],
            'balance'    => getPrice($userInfo[ 'balance' ]),
        ];
        _outPut(200, $res);
    }
}